home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-25 | 1.8 KB | 80 lines | [TEXT/?bDv] |
- !
- ! Bomber
- !
- ! This bot recognizes when it takes damage, and it tries to run
- ! away when it gets hit.
- ! Its weapon is a grenade launcher, not an ordinary gun.
- !
-
- #DATA
-
- EQU INCR 23
- EQU MINDIST 25
-
- DEF damage
- DEF scanAt
- DEF XX ! Destination coordinates
- DEF YY
- DEF goX ! Prepared velocities for running away
- DEF goY
-
- #CODE BASIC
-
- :Initialize
- Gosub CalcPos ! Pick a point to go to
- goX = goX * 20 ! Prepare to accelerate an awful lot
- goY = goY * 20
- damage = $DAMAGE ! Remember current damage level
-
- While (damage == $DAMAGE) ! Until I get hit
- begin
- ScanAt = ScanAt + INCR
- Scan Angle ScanAt
-
- ! Don't launch so close that you hit yourself! If the
- ! enemy is close, aim MINDIST pixels away. But, the
- ! first check is to see if something was found.
-
- If ($FOUND <> 0) Then If ($DISTANCE >= MINDIST) &
- Then Fire Weapon 1, Angle $ANGLE, Distance $DISTANCE
- Else Fire Weapon 1, Angle $ANGLE, Distance MINDIST
-
- ! Don't bother "locking" on to the enemy, because
- ! grenades are pretty slow to fire and detonate.
- end
-
- Goto Runaway
-
- :RAway
- Gosub CalcVel
- goX = goX * 2 ! Move there twice as fast.
- goY = goY * 2
- :Runaway
- Velocity goX, goY
- If (XX-$XLOC > 30) Then Goto RAway
- If (XX-$XLOC < -30) Then Goto RAway
- If (YY-$YLOC > 30) Then Goto RAway
- If (YY-$YLOC < -30) Then Goto RAway
-
- ! If we got this far, we must be within 30 pixels (both X
- ! and Y) of our destination. Close enough.
-
- Velocity 0, 0
- Goto Initialize ! Start all over again.
-
-
- ! These are subroutines. CALCVEL calculates the new velocity
- ! for moving to point XX,YY. CALCPOS does the same, except
- ! that it also picks random numbers between 20 and 235 for
- ! XX and YY.
-
- :CalcPos
- XX = Random(215) + 20
- YY = Random(215) + 20
- :CalcVel
- goX = XX - $XLOC
- goY = YY - $YLOC
- Return
-
- #END
-